package com.nmgydy.beans;

import com.alibaba.fastjson.JSON;

public class ResultBean{

	private boolean res;
	private String msg;
	private Object data;
	
	public ResultBean() {
		this.res = true;
		this.msg = "";
	}
	public ResultBean(boolean res, String msg,Object data) {
		this.res = res;
		this.msg = msg;
		this.data = data;
	}
	
	public boolean getRes() {
		return res;
	}
	public void setRes(boolean res) {
		this.res = res;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public static ResultBean success(Object data) {
		ResultBean resultBean = new ResultBean(true,"success",data);
		return resultBean;
	}
	
	public static ResultBean success(String msg,Object data) {
		ResultBean resultBean = new ResultBean(true,msg,data);
		return resultBean;
	}
	
	public static ResultBean failure() {
		ResultBean resultBean = new ResultBean(false,"failure",null);
		return resultBean;
	}
	
	public static ResultBean failure(String msg) {
		ResultBean resultBean = new ResultBean(false,msg,null);
		return resultBean;
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

}
